AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Ayuda / WLanguage / Funciones WLanguage / Funciones estándar / Funciones de archivos externos
  • Handling errors
  • Position in the file
  • ANSI/Unicode management
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
Reads a line in an external file.
Ejemplo
WINDEVWEBDEV - Código ServidorReportes y ConsultasJavaCódigo de Usuario (UMC)Ajax
// Ouverture d'un fichier externe
MonFichierTxt is DiskFile
ResLecture is string
IF MonFichierTxt.Ouvre("C:\MesRépertoires\Fichier.txt", foReadWrite) = True THEN
	// Lecture d'une ligne dans ce fichier
	ResLecture = MonFichierTxt.LitLigne()
	...
END
Sintaxis

Leer un archivo línea por línea Ocultar los detalles

<Result> = <File used>.ReadLine([<Separator>])
<Result>: Cadena de caracteres o cadena de caracteres Unicode
  • Line read in an external file.
  • EOT constant if the end of file has been reached.
  • Empty string ("") if an error occurred. In this case, the ErrorOccurred variable is set to True.
Note: A line ends with a carriage return (CR).
<File used>: Variable de tipo DiskFile
Name of the DiskFile variable initialized with <DiskFile variable>Abrir or <DiskFile variable>.Create.
<Separator>: Cadena de caracteres
Separator used between the lines. The default separator is the Carriage Return (CR).
WINDEVWEBDEV - Código ServidorReportes y ConsultasiPhone/iPadIOS WidgetJavaCódigo de Usuario (UMC)Ajax

Leer un archivo línea por línea mediante un procedimiento Ocultar los detalles

<Result> = fReadLine(<File used> , <WLanguage procedure> [, <Separator>])
<Result>: Entero
Number of lines read.
Note: A line ends with a carriage return (CR).
<File used>: Variable de tipo Integer o DiskFile
Name of the DiskFile variable initialized with <DiskFile variable>Abrir or <DiskFile variable>.Create.
<WLanguage procedure>: Nombre del procedimiento
Name of the WLanguage procedure ("callback") called for each line read in the file. This procedure is used to manipulate the current line. For more details on this procedure, see Parameters of the procedure used by fReadLine.
<Separator>: Cadena de caracteres
Separator used between the lines. The default separator is the Carriage Return (CR).
Observaciones

Handling errors

<DiskFile variable>.ReadLine throws an error in the following cases:
  • the file is not opened,
  • the file is not accessible in read mode,
  • the file is locked by another computer or by another application. <DiskFile variable>.Unlock is used to unlock an external file.

Position in the file

When opening a file, the current position corresponds to:
  • the first file byte (by default),
  • the last byte of the file is the file is opened in "addition" mode (foAdd constant).
This position can be modified by <DiskFile variable>.Seek.
<DiskFile variable>.ReadLine reads the specified elements from the current position. Once <DiskFile variable>.ReadLine has been executed, the current position is set to the last byte read. <DiskFile variable>.ReadLine returns the EOT constant if the end of the file has been reached.
WINDEVWEBDEV - Código ServidorReportes y ConsultasCódigo de Usuario (UMC)Ajax

ANSI/Unicode management

The <DiskFile variable>.ReadLine function reads:
  • a Unicode string in a Unicode file.
  • an Ansi string in an Ansi file.
The file is created or opened with <DiskFile variable>.Create/<DiskFile variable>Abrir by specifying the file type.
Depending on the format of the external file used, some conversions are required once a character string was read in an external file:
Current computer
External file
in ANSI format
(<DiskFile variable>Abrir or <DiskFile variable>.Create associated with the foAnsi constant)
External file
in Unicode format
(<DiskFile variable>Abrir or <DiskFile variable>.Create associated with the foUnicode constant)
<DiskFile variable>.ReadLine functionPC running WindowsRead operation in ANSI format
Can be converted to Unicode using <ANSI string>.AnsiToUnicode function
MobileReading in Unicode format
Conversion to ANSI possible with UnicodeToAnsi

Note If the result of the <DiskFile variable>.ReadLine function of an ANSI file is assigned to a Unicode string (and vice versa), the conversion will be implicitly performed.
For more details, see Unicode management
Clasificación Lógica de negocio / UI: Lógica de negocio
Componente: wd300std.dll
Versión mínima requerida
  • Versión 28
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 26/09/2024

Señalar un error o enviar una sugerencia | Ayuda local